package top.jiangqiang.qyblog.portal.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import top.jiangqiang.qyblog.common.base.controller.BaseController;
import top.jiangqiang.qyblog.common.base.query.PageResult;
import top.jiangqiang.qyblog.common.base.response.Result;
import top.jiangqiang.qyblog.common.constant.RequestURLConstants;
import top.jiangqiang.qyblog.core.domain.dto.FileQueryDto;
import top.jiangqiang.qyblog.core.domain.vo.FileVo;
import top.jiangqiang.qyblog.core.service.IFileService;

/**
 * @author jiangqiang
 * @date 2022-12-03
 */
@RequiredArgsConstructor
@RestController
@RequestMapping(RequestURLConstants.PUBLIC_FILE_CONTROLLER_PREFIX)
@Tag(name = "文件管理接口",description = "不建议暴露给前台使用，防止盗刷")
@Deprecated
public class PublicFileController extends BaseController {
    private final IFileService fileService;

    @GetMapping
    @Operation(summary = "根据条件查询文件列表", description = "根据条件查询文件列表")
    public Result<PageResult<FileVo>> list(@ParameterObject FileQueryDto query) {
        return Result.ok(fileService.findByCondition(query));
    }

    @GetMapping("/{id}")
    @Operation(summary = "查询文件详情", description = "根据id查询文件详情")
    public Result<FileVo> get(@PathVariable Long id) {
        return fileService.getFileDetail(id);
    }

}
